<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>E3不是父子模版，考虑其为模态视图</title>
		<link rel="stylesheet" type="text/css" href="../css/mui.min.css" />
		<link rel="stylesheet" type="text/css" href="../css/iconfont.css" />
		
		<style type="text/css">
			/*下面两项是重置muicss的输入框label和input之间的宽比率*/
			
			.mui-input-row label {
				width: 30%;
			}
			
			.mui-input-row label~input {
				/*width: 80%;*/
				float: left;
			}
			
			
		a{
    		color: #000000;
    	}
    	.mui-bar .mui-btn-nav.mui-pull-left{
    		margin-left: 10px;
    	}
    	.mui-bar .mui-btn-link{
    		color: #000000;
    		
    	}
    	.mui-btn-link{
    		color: #000000;
    	}
		
		</style>
	</head>

	<body>

		<header class="mui-bar mui-bar-nav">
        <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
        <span class="mui-action-back mui-btn-link mui-btn-nav mui-pull-left">用户登录</span>
        <span class="mui-icon iconfont icon-menu mui-pull-right"></span>
    	</header>

		<div class="mui-content">
			<!--<div style="margin-top: 30px; text-align: center;">
				<span class="mui-icon mui-icon-person" style="font-size: 4em; border: 2px solid gray; border-radius: 50%; color: gray;"></span>
			</div>-->
			<div class="mui-card" style="margin-top: 20px;">
				<form class="mui-input-group">
					<div class="mui-input-row">
						<label><span style="width: 50px;">用户名</span></label>
						<input type="text" class="mui-input-clear" value="yunfei" placeholder="请输入手机号或邮箱" />
					</div>
					<div class="mui-input-row">
						<label><span style="width: 50px;">密&nbsp;&nbsp;&nbsp;码</span></label>
						<input type="password" class="mui-input-clear" value="qem123456" placeholder="请输入密码" />
					</div>
				</form>
			</div>
			<div class="mui-button-row" style="margin: 10px 15px;">
				<button id="loginBtn" type="button" class="mui-btn mui-btn-green own-btn-green mui-btn-block " style="padding: 5px 0px;" onclick="logined();">登录</button>
			</div>
			<div class="mui-button-row" style="padding-top: 0px;">
				<button id="register" type="button" class="mui-btn mui-btn-link own-main-color own-font-size" style="padding-top: 0px; margin-right: 60px; ">快速注册</button>
				<button id="repsd" type="button" class="mui-btn mui-btn-link own-font-size" style="padding-top: 0px; margin-left: 60px; color: #FF6A6A;">忘记密码</button>
			</div>

		</div>

		<script src="../js/mui.min.js" charset="UTF-8"></script>
		<script src="../js/own.js" charset="UTF-8"></script>
		<!--<script src="../js/.js" charset="UTF-8"></script>-->
		<script type="text/javascript" src="../js/common.js" ></script>
		<script type="text/javascript" charset="UTF-8">
			mui.init({
				swipeBack: true
			});
			var account;
			var psd;
			var login;
			var register;
			var repsd;
			var loginWebview;
			
			account = document.querySelector('input[type="text"]');
			psd = document.querySelector('input[type="password"]');
			login = document.getElementById('loginBtn');
			
			var reqUrl = "Leather/Home/AjaxService/SelLogindata.ashx";
			var data = {
				lFlag:1,
				loginName:account.value,
				loginPassword:psd.value,
			}
			mui.plusReady(function() {
				
				
				
				
				//登陆的点击事件
//				login.addEventListener('tap', function() {
				
				
//				logined();
			});
			
			
			function logined(){
				
					ajax_login_new("Leather/Home/AjaxService/SelLogindata.ashx",data,loginSuccess)
					
				}
			
			function loginSuccess(loginMsg){
					
					console.log(loginMsg.flag)
					if(loginMsg.flag == "1"){
						localStorage.setItem('userCompId', loginMsg.msg._companyID);
						localStorage.setItem('userName',loginMsg.msg._userName);
						localStorage.setItem('userId',loginMsg.msg._userID);
						localStorage.setItem('userCompName',loginMsg.msg._companyName);
//						localStorage.setItem('cghtflag',loginMsg.msg.)
						localStorage.setItem("flag",1);
//						mui.back();
						mui.toast('登录成功');
					}else{
						//如果登录失败，清空密码
						account.text = "";
						psd.text = "";
						localStorage.setItem('user', loginMsg.msg);
						localStorage.setItem("flag",-1);
					}
					localStorage.setItem('account',account.value); 
				//将两个数据存放起来，第一个是等出之后删除，第二个只要登录之后就会记录保存
//					console.log(localStorage.getItem('account'))
//					
					loginWebview = plus.webview.currentWebview();
//					console.log(localStorage.getItem('account'))
//					//检测本地的登录过的账号。
//					if (localStorage.getItem('account') != null) {
//						account.value = localStorage.getItem('account');
//					}
					//添加事件接收close事件，并且要判断是否已经登录成功，然后页面close，因为login页面是预先加载的页面
					//在这里向需要的页面发送消息事件通知已经登录做响应的处理
//					loginWebview.addEventListener('hide', function() {
//						mui.each(plus.webview.all(), function(index, item) {
//							console.log(item.id)
//						})
//						var cartwebview = plus.webview.getWebviewById('barItem/cart.html');
//						var minewebview = plus.webview.getWebviewById('barItem/mine.html');
//						var xinyuandanwebview = plus.webview.getWebviewById('barItem/wishList.html');
//						mui.fire(cartwebview, 'loginSuccess', {});
//						mui.fire(minewebview, 'loginSuccess', {});
//						mui.fire(xinyuandanwebview, 'loginSuccess', {});
						loginWebview.close();
						loginWebview.close();
//					}, false);
//				}, false);
				
			}
			register = document.getElementById('register');
			//注册按钮的点击事件
				register.addEventListener('tap', function() {
//					pushWebView({
//						webType: 'newWebview_First',
//						id: 'register-needtem.html',
//						href: 'register-needtem.html',
//						aniShow: getaniShow(),
//						title: "注册",
//						isBars: false,
//						barsIcon: '',
//						extendOptions: {}
//					})
					mui.openWindow({
						url:"register-needtem.html",
						id:'register-needtem.html',
	//					waiting{
	//						autoShow:false
	//					},
						createNew:false
					});
				}, false);
				
				repsd = document.getElementById('repsd');
				
				//注册按钮的点击事件
				repsd.addEventListener('tap', function() {
//					pushWebView({
//						webType: 'newWebview_First',
//						id: 'mine/forget-psd-needtem.html',
//						href: 'mine/forget-psd-needtem.html',
//						aniShow: getaniShow(),
//						title: "注册",
//						isBars: false,
//						barsIcon: '',
//						extendOptions: {}
//					})
					mui.openWindow({
						url:"forget-psd-needtem.html",
						id:'forget-psd-needtem.html',
	//					waiting{
	//						autoShow:false
	//					},
						createNew:false
					});
				}, false);
		</script>
	</body>

</html>